import atlas from "@/atlas";
import server from "@/server";
import Store from "@/store";
const callCloudPay = (obj, cpCode, productId) => {
    const allConfigs = Store.getData("allConfigs");
    const province = allConfigs.PROVINCE;
    switch (province) {
        case "sx":
            if (
                !(
                    allConfigs.CONFIG_CPCODE_LIST &&
                    cpCode &&
                    allConfigs.CONFIG_CPCODE_LIST.indexOf(cpCode) > -1
                )
            ) {
                if (obj.psid) {
                    obj.psid = "s_" + obj.psid;
                }
                if (obj.psId) {
                    obj.psId = "s_" + obj.psId;
                }
                if (obj.contentId) {
                    obj.contentId = "s_" + obj.contentId;
                }
            }
            break;
        default:
            break;
    }

    if (allConfigs.QUERY_TYPE === "2") {
        // productId传空，launcher那边会设置type=2
        obj.productId = "";
    }
    // 产品包鉴权
    if (productId) {
        obj.productId = productId;
    }
    //拉起云支付的时候携带trace_id
    if (server.userInfo && server.userInfo.deviceId) {
        const time = Store.getData("payTime");
        obj.trace_id = server.userInfo.deviceId + "_" + time;
    }
    console.log("toOrder", JSON.stringify(obj))
    atlas.onLauncherCall("toOrder", JSON.stringify(obj));
};
export { callCloudPay };
